//
//  GongLvCollectionViewCell.m
//  礼物说
//
//  Created by dllo on 16/4/26.
//  Copyright © 2016年 sunzhichao. All rights reserved.
//

#import "GongLvCollectionViewCell.h"

@interface GongLvCollectionViewCell ()

@property (nonatomic, retain) BaseImageView * imgView;
@property (nonatomic, retain) BaseLabel * title;

@end

@implementation GongLvCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createCell];
    }
    return self;
}
- (void)dealloc{
    
    [_title release];
    [_imgView release];
    [_giftmodel release];
    [_model release];
    
    
    [super dealloc];
}

#pragma mark - 属性传值重写set方法
- (void)setModel:(StrategyModel *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    [_imgView sd_setImageWithURL:[NSURL URLWithString:_model.icon_url] placeholderImage:[UIImage imageNamed:@""]];
    _title.text = _model.name;
    
}
- (void)setGiftmodel:(GiftModel *)giftmodel{
    if (_giftmodel != giftmodel) {
        [_giftmodel release];
        _giftmodel = [giftmodel retain];
        
    }
    
    [_imgView sd_setImageWithURL:[NSURL URLWithString:_giftmodel.icon_url] placeholderImage:[UIImage imageNamed:@""]];
    
    _title.text = _giftmodel.name;
    
};


- (void)createCell{
    
    self.imgView = [[BaseImageView alloc] init];
    [self.contentView addSubview:_imgView];
    [_imgView release];
    
    self.title = [[BaseLabel alloc] init];
    [self.contentView addSubview:_title];
    [_title release];
    
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    _imgView.frame = CGRectMake(kWIDTHS(10), kWIDTHS(10), kWIDTHCELL - 20, kHEIGHTCELL - kWIDTHS(40));
    _imgView.layer.cornerRadius = 10;
    _imgView.layer.masksToBounds = YES;
    
    _title.frame = CGRectMake(0, kHEIGHTCELL -  kWIDTHS(20), kWIDTHCELL, kHEIGHTS(20));
    _title.textAlignment = NSTextAlignmentCenter;
}


@end
